Area of Interest / Fetch Statistics Plugin#93
Open
BhattaraiSijan wants to merge 24 commits into
Open
Conversation
This reverts commit c0455ea.
…re-up
Reverts the Prettier-style whitespace changes that drifted in over the
branch's life. The only functional change vs feat/imapengine-drawing now
is the engine.onFeatureClick → mmgisAPI.emit('map:featureClick') line,
which AOI's inspect mode depends on.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Adds the AOI plugin — pick an area of interest on the map (search / inspect / draw / upload) — and a companion background plugin (FetchStats) that runs per-layer statistics analysis against every visible analysis-supported layer. FetchStats publishes keyed results on the mmgisAPI event bus for downstream consumers (e.g. the Chart plugin) to render.
Proposed Changes
[ADD] src/essence/Tools/AOI/— draw/select pluginAOITool.js— MMGIS wrapper; only file in the plugin that touches mmgisAPIAOIComponent.tsx+.scss+_aoi-tokens.scss— panel UI (Search / Inspect / Draw / Upload modes + Analyzing progress overlay)AOITooltip.tsx— anchored "Analyze area / Cancel" confirm popoveraoiHelpers.ts— pure parse / search / centroid / bounds helpersaoiBoundaryLoader.ts— webpack require.context discovery + lazy fetch + dedupconfig.json— Configure UI registration[ADD] src/essence/Tools/FetchStats/— no-UI background pluginFetchStatsTool.js— subscribes toplugin:aoi:analysisAOIReady, POSTs each visible analysis-supported layer to its stats endpoint in parallel, emits progress + resultsconfig.json— Configure UI registration (no panel, auto-initializes viainitialize())[ADD]54 bundled GeoJSON boundariesUnder
src/essence/Tools/AOI/assets/geo-data/states/(50 states + DC + PR + US + US-contiguous + sample).[ADD]Bus surfaceAOI plugin (auto-prefixed
plugin:aoi:)areaDrawn{ feature, source: 'search'|'draw'|'upload'|'inspect', layerName }analysisAOIReady{ feature }drawingCleared{}drawingCancelled{}getCurrentSelection{ feature, source } | nulltool:changemap:drawstart / drawvertex / drawcomplete / drawcancelmap:featureClickplugin:fetch-stats:analysisProgress{ done, total }— drives progress barplugin:fetch-stats:analysisReady{ analysisData }— dismisses overlaymap:createLayer / removeLayermap:fitBoundsmap:enableDrawing / finishDrawing / disableDrawingmap:addOverlay / removeOverlayFetchStats plugin (auto-prefixed
plugin:fetch-stats:)analysisProgress{ done: number, total: number }analysisReady{ analysisData: { [layerDisplayName]: <stats response | null> } }plugin:aoi:analysisAOIReady{ feature }layers:getVisiblelayers:getAlllayers:getConfig[ADD]Map_.js wire-upOne bus wire-up in
src/essence/Basics/Map_/Map_.js(4 lines):Exposes the engine adapter's existing per-feature click handler on the bus so plugin-created vector layers (Inspect-mode boundaries) can receive clicks without going through the standard MMGIS layer pipeline. Engine-agnostic — both LeafletAdapter and DeckGLAdapter already implement
onFeatureClick.[ADD]Per-layer opt-in mission config[ADD]DependenciesRuntime:
@trussworks/react-uswds,@uswds/uswds,shpjs. Dev:@types/jest,sass.[NOTE]Mission setup requiredBoth AOI and FetchStats must be added to the mission's tools list in the Configure page for the full analysis flow to activate.
Issues
Closes #81
Testing
Manually tested on a DeckGL mission with two analysis-supported layers (Sentinel2-Colorir-Daily, Sentinel-2 dNBR):
areaDrawnfires withsource: 'search'areaDrawnfires withsource: 'inspect'drawcompleteflows into selection.geojson,.json,.kml,.zip(shapefile with.shp/.dbf/.prj) → each parses into a selectionanalysisAOIReady, discovers visible analysis-supported layers, fires parallel POSTs; progress bar fills viaanalysisProgressevents; overlay dismisses onanalysisReady/statisticsPOST returns non-2xx come back asnullentries inanalysisData; the run still succeeds for other layersplugin:fetch-stats:analysisReadyand renders the resultsTested on macOS, Chrome.
Known follow-ups
plugin:fetch-stats:analysisReadyis in a separate PR (Adds Chart plugin #94) and must be merged after this one